package org.example.software.service.impl;

import org.example.software.entity.Tools;
import org.example.software.mapper.ToolsMapper;
import org.example.software.service.ToolsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ToolsServiceImpl implements ToolsService {
    @Autowired
    private ToolsMapper toolsMapper;

    @Override
    // 添加工具
    public boolean addTools(Tools tools) {
        return toolsMapper.insert(tools) > 0;
    }

    @Override
    // 删除工具
    public boolean deleteToolsById(int id) {
        return toolsMapper.deleteById(id) > 0;
    }

    @Override
    // 修改工具信息
    public boolean updateTools(Tools tools) {
        return toolsMapper.updateById(tools) > 0;
    }

    @Override
    // 根据 ID 查询工具
    public List<Tools> getToolsById(int id) {
        return toolsMapper.getToolsById(id);
    }

    // 根据 制造商 查询工具
    public List<Tools>  getToolsByName(String manufacturerName) {
        return toolsMapper.getToolsByName(manufacturerName);
    }

    // 根据 工具名 查询工具
    public List<Tools>  getToolsByToolName(String toolName) {
        return toolsMapper.getToolsByToolName(toolName);
    }

    // 查找全部工具
    @Override
    public List<Tools> getAllTools() {
        List<Tools> tools = toolsMapper.selectList(null);
        return tools;
    }

}
